/*
 * Copyright 2018 Zhongan.com All right reserved. This software is the
 * confidential and proprietary information of Zhongan.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Zhongan.com.
 */

package com.yh.create.Multition_parttern;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * TODO 类实现描述
 *
 * @author yanghui
 * @since 2018年7月12日 下午11:30:16
 */
public class King {
    private static int MAX_COUNT_OF_KING = 2;
    private static List<String> kingInfoList = new ArrayList<>(MAX_COUNT_OF_KING);
    private static List<King> kingList = new ArrayList<>(MAX_COUNT_OF_KING);
    private static int currentKind = 0;

    static {
        for (int i = 0; i < MAX_COUNT_OF_KING; i++) {
            kingList.add(new King("皇" + (i + 1) + "帝"));
        }
    }

    private King() {

    }

    private King(String info) {
        kingInfoList.add(info);
    }

    public static King getNewInstance() {

        Random random = new Random();
        currentKind = random.nextInt(MAX_COUNT_OF_KING);
        return kingList.get(currentKind);
    }

    public static void kingInfo() {
        System.out.println(kingInfoList.get(currentKind));
    }

}
